package com.level.system.task;

import com.alibaba.fastjson.JSON;
import com.level.system.entity.emr.DATA_HZ;
import com.level.system.service.EmrParseService;
import com.level.system.util.EmrParserUtil;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.util.*;
import java.util.stream.Collectors;

public class HZ_24HRCYJLThread extends Thread {

    private List<DATA_HZ> taskList;
    private EmrParseService emrService;

    public HZ_24HRCYJLThread(List<DATA_HZ> list, EmrParseService service) {
        this.taskList = list;
        this.emrService = service;
    }

    @Override
    public void run() {
        handleTask(this.taskList);
    }

    private void handleTask(List<DATA_HZ> list) {
        List<Map<String, Object>> ryjlList = new ArrayList<>();
        Map<String, Object> ryjlMap = new HashMap<>();

        List<Map<String, Object>> cyjlList = new ArrayList<>();
        Map<String, Object> cyjlMap = new HashMap<>();

        for (Iterator it = list.iterator(); it.hasNext(); ) {
            // 1获取病历对象
            DATA_HZ emrParser = (DATA_HZ) it.next();
            // 2获取病历html
            String html = new String(emrParser.getMRCONTENT());
            // 3获取病历解析结果
            Map<String, Object> map = get24hRcyjl(html);
            map.put("jgid", emrParser.getJGID());
            map.put("id", emrParser.getID());
            map.put("mcNo", emrParser.getMCNO());
            map.put("docId", emrParser.getDOCID());
            map.put("mzzy", emrParser.getMZZY());
//            map.put("emrType", emrParser.getEMRTYPE());
            map.put("archiveTime", emrParser.getARCHIVETIME());
            map.put("rysj", emrParser.getRYSJ());
            map.put("cysj", emrParser.getCYSJ());

            map.put("name", emrParser.getNAME());
            map.put("sex", emrParser.getSEX());
            map.put("birthday", emrParser.getBIRTHDAY());

            map.put("creater", "dba");
            map.put("createTime", new Date());

            map.put("cjr", emrParser.getCJR());
            map.put("cjsj", emrParser.getCJSJ());
            map.put("xgr", emrParser.getXGR());
            map.put("xgsj", emrParser.getXGSJ());
            map.put("jlsj", emrParser.getJLSJ());

            //24h入院记录
            map.put("emrType", "3");
            map.put("templateType", "3");
            ryjlList.add(map);
            //24h出院记录
            Map<String, Object> cymap = new HashMap<>();
            cymap.putAll(map);
            cymap.put("emrType", "9");
            cymap.put("templateType", "9");
            cyjlList.add(cymap);
        }
        ryjlMap.put("list", ryjlList);
        emrService.batchSaveHZ(ryjlMap);

        cyjlMap.put("list", cyjlList);
        emrService.batchSaveHZ(cyjlMap);
    }

    /**
     * 获取基本元素内容
     *
     * @param element
     * @return
     */
    private static String getMRElementXmlText(Element element) {
        //1替换空格2提取leftbrackets、rightbrackets节点内容
        String tempHtml = element.html();
        tempHtml = tempHtml.replaceAll("&nbsp;", "");
        element.html(tempHtml);

        String text = element.text().trim();
        if (text.length() > 0) {
            // 去掉[
            text = text.substring(1, text.length());
            // 去掉]
            if (text.length() > 0) {
                text = text.substring(0, text.length() - 1);
            }
        }
        return text.trim();
    }

    /**
     * 获取元素内容
     *
     * @param element
     * @return
     */
    private static String getMRXmlText(Element element) {
        String levelchapter = element.attr("levelchapter");
        Map<String, Object> chapterMap = JSON.parseObject(levelchapter);
        // 获取默认值属性
        String chapterId = chapterMap.get("chapterId").toString();
        // 1移除levelplugins=nodeblock
        element.select("span[levelplugins='nodeblock']").remove();
        // 2提取leftbrackets、rightbrackets节点内容

        // 替换空格
        String tempHtml = element.html();
        tempHtml = tempHtml.replaceAll("&nbsp;", " ");
        element.html(tempHtml);

        String text = element.text().trim();
        // System.out.println("element.html " + element.html());
        if (text.length() > 0) {
            // 去掉[
            text = text.substring(1, text.length());
            // 去掉]
            if (text.length() > 0) {
                text = text.substring(0, text.length() - 1);
            }
        }
        // System.out.println("chapterId " + chapterMap);
        // System.out.println("text " + text);
        return text.trim();
    }

    /**
     * 获取24h入出院记录
     *
     * @param html
     * @return
     */
    public Map<String, Object> get24hRcyjl(String html) {
        Map<String, Object> map = new HashMap<>();
        map.put("state", "0");
        // 病历文书内容
        Document doc = Jsoup.parseBodyFragment(html);
        //基本元素
        //todo 体格检查
        Elements elements = doc.select("span[levelplugins='element']");
        for (Iterator it = elements.iterator(); it.hasNext(); ) {
            Element element = (Element) it.next();
            // 获取有level-model属性的span
            Elements simples = element.select("span[level-model]");
            for (int k = 0; k < simples.size(); k++) {
                Element simple = simples.get(k);
                String levelModel = simple.attr("level-model");
                Map<String, Object> modelMap = JSON.parseObject(levelModel);
                // 获取默认值属性
                String elementId = modelMap.get("elementId").toString();

                //todo 一般状况 检查结果
                if ("BE-1001-1007-1006-1001".equals(elementId)) {
                    //血压值（收缩压）（mmHg)
                    map.put("sbp", getMRElementXmlText(element));
                }
                if ("BE-1001-1007-1006-1002".equals(elementId)) {
                    //血压值（舒张压）（mmHg)
                    map.put("dbp", getMRElementXmlText(element));
                }
                if ("BE-1001-1007-1004-1001".equals(elementId)) {
                    // 体温（℃）
                    map.put("temperature", getMRElementXmlText(element));
                }
                if ("BE-1001-1007-1004-1002".equals(elementId)) {
                    //心率（次/分）
                    map.put("heartrate", getMRElementXmlText(element));
                }
                if ("BE-1001-1007-1004-1003".equals(elementId)) {
                    //呼吸（次/分）
                    map.put("breathrate", getMRElementXmlText(element));
                }
                if ("BE-1001-1007-1006-1003".equals(elementId)) {
                    //身高（cm）
                    map.put("height", getMRElementXmlText(element));
                }
                if ("BE-1001-1007-1006-1004".equals(elementId)) {
                    //体重（kg）
                    map.put("weight", getMRElementXmlText(element));
                }
                if ("BE-1001-1007-1001-1003".equals(elementId)) {
                    //意识 consciousness
                    map.put("consciousness", getMRElementXmlText(element));
                }
                if ("BE-1001-1007-1001-1001".equals(elementId)) {
                    //体位 position
                    map.put("position", getMRElementXmlText(element));
                }
                if ("BE-1001-1007-1001-1004".equals(elementId)) {
                    //病容 sicklylook
                    map.put("sicklylook", getMRElementXmlText(element));
                }
                if ("BE-1001-1007-1001-1002".equals(elementId)) {
                    //合作 cooperation
                    map.put("cooperation", getMRElementXmlText(element));
                }

                //todo 皮肤和黏膜检查结果
                if ("BE-1001-1007-1001-1017".equals(elementId)) {
                    //色泽 colourandlustre
                    map.put("colourandlustre", getMRElementXmlText(element));
                }
                if ("BE-1001-1007-1003-1014".equals(elementId)) {
                    //水肿 edema
                    map.put("edema", getMRElementXmlText(element));
                }
                if ("BE-1001-1007-1003-1015".equals(elementId)) {
                    //皮疹 erythra
                    map.put("erythra", getMRElementXmlText(element));
                }
                if ("BE-1001-1007-1003-1016".equals(elementId)) {
                    //出血 haemorrhage
                    map.put("haemorrhage", getMRElementXmlText(element));
                }

                //todo 全身浅表淋巴结检查结果
                if ("BE-1001-1007-1003-1024".equals(elementId)) {
                    map.put("physexm_spef_lymph", getMRElementXmlText(element));
                }

                //todo 头部及其器官检查结果

                //todo 头
                if ("BE-1001-1007-1002-1002".equals(elementId)) {
                    //头部外形 headshape
                    map.put("headshape", getMRElementXmlText(element));
                }
                if ("BE-1001-1007-1001-1012".equals(elementId)) {
                    //头部头皮 headscalp
                    map.put("headscalp", getMRElementXmlText(element));
                }
                if ("BE-1001-1007-1001-1011".equals(elementId)) {
                    //头部头发 headhair
                    map.put("headhair", getMRElementXmlText(element));
                }

                //todo 眼
                if ("BE-1001-1007-1002-1051".equals(elementId)) {
                    //眼球 eyeball
                    map.put("eyeball", getMRElementXmlText(element));
                }
                if ("BE-1001-1007-1002-1030".equals(elementId)) {
                    //眼睑 eyelid
                    map.put("eyelid", getMRElementXmlText(element));
                }
                if ("BE-1001-1007-1002-1052".equals(elementId)) {
                    //结膜 conjunctiva
                    map.put("conjunctiva", getMRElementXmlText(element));
                }
                if ("BE-1001-1007-1002-1003".equals(elementId)) {
                    //巩膜 sclera
                    map.put("sclera", getMRElementXmlText(element));
                }
                if ("BE-1001-1007-1002-1037".equals(elementId)) {
                    //角膜 corneal
                    map.put("corneal", getMRElementXmlText(element));
                }
                if ("BE-1001-1007-1002-1026".equals(elementId)) {
                    //瞳孔 pupil
                    map.put("pupil", getMRElementXmlText(element));
                }

                //todo 耳
                if ("BE-1001-1007-1002-1053".equals(elementId)) {
                    //外耳道 externalauditorycanal
                    map.put("externalauditorycanal", getMRElementXmlText(element));
                }
                if ("BE-1001-1007-1002-1038".equals(elementId)) {
                    //听力粗测 roughlisteningtest
                    map.put("roughlisteningtest", getMRElementXmlText(element));
                }

                //todo 鼻
                if ("BE-1001-1007-1002-1054".equals(elementId)) {
                    //鼻外形 noseshape
                    map.put("noseshape", getMRElementXmlText(element));
                }
                if ("BE-1001-1007-1002-1027".equals(elementId)) {
                    //鼻通气 nasalventilation
                    map.put("nasalventilation", getMRElementXmlText(element));
                }
                if ("BE-1001-1006-1007-1007".equals(elementId)) {
                    //副鼻窦压痛 tendernessofparanasalsinus
                    map.put("tendernessofparanasalsinus", getMRElementXmlText(element));
                }

                //todo 口腔
                if ("BE-1001-1007-1002-1040".equals(elementId)) {
                    //唇色 lipcolor
                    map.put("lipcolor", getMRElementXmlText(element));
                }
                if ("BE-1001-1007-1002-1006".equals(elementId)) {
                    //口腔粘膜 oralmucosa
                    map.put("oralmucosa", getMRElementXmlText(element));
                }
                if ("BE-1001-1007-1002-1041".equals(elementId)) {
                    //牙齿 tooth
                    map.put("tooth", getMRElementXmlText(element));
                }
                if ("E-1001-1007-1002-1042".equals(elementId)) {
                    //齿龈 gums
                    map.put("gums", getMRElementXmlText(element));
                }
                if ("BE-1001-1007-1002-1043".equals(elementId)) {
                    //舌 tongue
                    map.put("tongue", getMRElementXmlText(element));
                }
                if ("BE-1001-1007-1002-1044".equals(elementId)) {
                    //腮腺 parotidgland
                    map.put("parotidgland", getMRElementXmlText(element));
                }
                if ("BE-1001-1007-1002-1045".equals(elementId)) {
                    //咽 pharynx
                    map.put("pharynx", getMRElementXmlText(element));
                }
                if ("BE-1001-1007-1002-1014".equals(elementId)) {
                    //扁桃体 tonsil
                    map.put("tonsil", getMRElementXmlText(element));
                }

                //todo 颈部检查结果
                if ("BE-1001-1007-1002-1014".equals(elementId)) {
                    //甲状腺 thyroid
                    map.put("thyroid", getMRElementXmlText(element));
                }
                if ("BE-1001-1007-1002-1009".equals(elementId)) {
                    //颈静脉 jugularvein
                    map.put("jugularvein", getMRElementXmlText(element));
                }
                if ("BE-1001-1007-1002-1008".equals(elementId)) {
                    //气管位置 positionoftrachea
                    map.put("positionoftrachea", getMRElementXmlText(element));
                }

                //todo 胸部检查结果
                if ("BE-1001-1007-1002-1010".equals(elementId)) {
                    //胸廓形状 thoracicshape
                    map.put("thoracicshape", getMRElementXmlText(element));
                }
                if ("BE-1001-1007-1001-1023".equals(elementId)) {
                    //胸部呼吸 chestbreathing
                    map.put("chestbreathing", getMRElementXmlText(element));
                }
                if ("BE-1001-1007-1001-1024".equals(elementId)) {
                    //胸壁 chestwall
                    map.put("chestwall", getMRElementXmlText(element));
                }
                if ("BE-1001-1007-1002-1011".equals(elementId)) {
                    //肋间隙 costalpace
                    map.put("costalpace", getMRElementXmlText(element));
                }
                if ("BE-1001-1007-1002-1012".equals(elementId)) {
                    //乳房 breast
                    map.put("breast", getMRElementXmlText(element));
                }

                //todo 腹部检查结果
                if ("BE-1001-1007-1003-1001".equals(elementId)) {
                    //腹部外形 abdominalshape
                    map.put("abdominalshape", getMRElementXmlText(element));
                }
                if ("BE-1001-1007-1006-1005".equals(elementId)) {
                    //蠕波动 creepwave
                    map.put("creepwave", getMRElementXmlText(element));
                }
                if ("BE-1001-1007-1002-1018".equals(elementId)) {
                    //腹壁紧张度 bdominalwalltension
                    map.put("bdominalwalltension", getMRElementXmlText(element));
                }
                if ("BE-1001-1007-1003-1020".equals(elementId)) {
                    //腹部压痛 abdominaltenderness
                    map.put("abdominaltenderness", getMRElementXmlText(element));
                }
                if ("BE-1001-1007-1006-1007".equals(elementId)) {
                    //反跳痛 reboundpain
                    map.put("reboundpain", getMRElementXmlText(element));
                }
                if ("BE-1001-1007-1003-1013".equals(elementId)) {
                    //腹部包块 abdominalmass
                    map.put("abdominalmass", getMRElementXmlText(element));
                }
                if ("BE-1001-1007-1006-1006".equals(elementId)) {
                    //肝脏 hepar
                    map.put("hepar", getMRElementXmlText(element));
                }
                if ("BE-1001-1007-1006-1009".equals(elementId)) {
                    //胆囊 gallbladder
                    map.put("gallbladder", getMRElementXmlText(element));
                }
                if ("BE-1001-1007-1006-1010".equals(elementId)) {
                    //脾脏 spleen
                    map.put("spleen", getMRElementXmlText(element));
                }
                if ("BE-1001-1007-1002-1029".equals(elementId)) {
                    //肾区叩痛 renalpercussionpain
                    map.put("renalpercussionpain", getMRElementXmlText(element));
                }
                if ("BE-1001-1007-1003-1004".equals(elementId)) {
                    //肠鸣音 bowelsounds
                    map.put("bowelsounds", getMRElementXmlText(element));
                }
                if ("BE-1001-1007-1002-1021".equals(elementId)) {
                    //移动性浊音 mobilevoicedsound
                    map.put("mobilevoicedsound", getMRElementXmlText(element));
                }

                //todo 肛门指诊检查结果描述
                if ("BE-1001-1007-1006-1011".equals(elementId)) {
                    map.put("physexm_finger_exam", getMRElementXmlText(element));
                }

                //todo 外生殖器检查结果
                if ("BE-1001-1007-1006-1012".equals(elementId)) {
                    map.put("physexm_genital_area", getMRElementXmlText(element));
                }

                //todo 脊柱检查结果
                if ("BE-1001-1007-1006-1013".equals(elementId)) {
                    //脊柱畸形 spinaldeformity
                    map.put("spinaldeformity", getMRElementXmlText(element));
                }

                //todo 四肢检查结果
                if ("BE-1001-1007-1001-1016".equals(elementId)) {
                    map.put("physexm_all_fors", getMRElementXmlText(element));
                }

                //todo 神经系统检查结果
//                if ("".equals(elementId)) {
//                    //深浅感觉 depthfeeling
//                    map.put("depthfeeling", getMRElementXmlText(element));
//                }
//                if ("".equals(elementId)) {
//                    //深反射 deepreflection
//                    map.put("deepreflection", getMRElementXmlText(element));
//                }
//                if ("".equals(elementId)) {
//                    //浅反射 shallowreflection
//                    map.put("shallowreflection", getMRElementXmlText(element));
//                }
//                if ("".equals(elementId)) {
//                    //病理反射 pathologicalreflex
//                    map.put("pathologicalreflex", getMRElementXmlText(element));
//                }
//                if ("".equals(elementId)) {
//                    //脑膜刺激征 meningealstimulationsign
//                    map.put("meningealstimulationsign", getMRElementXmlText(element));
//                }
                if ("BE-1001-1007-1006-1014".equals(elementId)) {
                    //其他 othernervoussystem
                    map.put("othernervoussystem", getMRElementXmlText(element));
                }

            }
        }

        //章节元素
        Elements lcs = doc.select("span[levelchapter]");
        for (Iterator it = lcs.iterator(); it.hasNext(); ) {
            Element lc = (Element) it.next();
            String levelchapter = lc.attr("levelchapter");
            // 转成map对象
            Map<String, Object> chapterMap = JSON.parseObject(levelchapter);
            // 获取默认值属性
            String chapterId = chapterMap.get("chapterId").toString();
            if ("MR-1001-1002-1001".equals(chapterId)) {
                // 主诉
                map.put("chiefcomplaint", EmrParserUtil.subStr(getMRXmlText(lc), 4000));
            }
            if ("MR-1001-1002-1002".equals(chapterId)) {
                // 现病史
                map.put("medicalhistory", EmrParserUtil.subStr(getMRXmlText(lc), 4000));
            }
            if ("MR-1001-1002-1003".equals(chapterId)) {
                // 既往史
                map.put("pasthistory", EmrParserUtil.subStr(getMRXmlText(lc), 4000));
            }
            if ("MR-1001-1002-1006".equals(chapterId)) {
                // 个人史
                map.put("personalhistory", EmrParserUtil.subStr(getMRXmlText(lc), 1000));
            }
            if ("MR-1001-1002-1014".equals(chapterId)) {
                // 婚育史
                map.put("childbearinghistory", EmrParserUtil.subStr(getMRXmlText(lc), 1000));
            }
            if ("MR-1001-1002-1008".equals(chapterId)) {
                // 家族史
                map.put("familyhistory", EmrParserUtil.subStr(getMRXmlText(lc), 1000));
            }
            if ("MR-1001-1002-1025".equals(chapterId)) {
                // 喂养史
                map.put("feedinghistory", EmrParserUtil.subStr(getMRXmlText(lc), 500));
            }
            if ("MR-1001-1002-1026".equals(chapterId)) {
                // 出生史
                map.put("birthhistory", EmrParserUtil.subStr(getMRXmlText(lc), 500));
            }
            if ("MR-1001-1002-1007".equals(chapterId)) {
                // 月经史
                map.put("menstrualhistory", EmrParserUtil.subStr(getMRXmlText(lc), 1000));
            }
            if ("MR-1001-1002-1027".equals(chapterId)) {
                // 过敏史
                map.put("allergichistory", EmrParserUtil.subStr(getMRXmlText(lc), 1000));
            }
            if ("MR-1001-1002-1028".equals(chapterId)) {
                // 外伤史
                map.put("traumahistory", EmrParserUtil.subStr(getMRXmlText(lc), 1000));
            }
            if ("MR-1001-1002-1029".equals(chapterId)) {
                // 手术史
                map.put("operationhistory", EmrParserUtil.subStr(getMRXmlText(lc), 1000));
            }
            if ("MR-1001-1002-1005".equals(chapterId)) {
                // 输血史
                map.put("transfusionhistory", EmrParserUtil.subStr(getMRXmlText(lc), 1000));
            }
            if ("MR-1001-1002-1030".equals(chapterId)) {
                // 疾病史
                map.put("diseasehistory", EmrParserUtil.subStr(getMRXmlText(lc), 1000));
            }
            if ("MR-1001-1002-1031".equals(chapterId)) {
                // 传染病史
                map.put("infectioushistory", EmrParserUtil.subStr(getMRXmlText(lc), 1000));
            }
            if ("MR-1001-1002-1004".equals(chapterId)) {
                // 预防接种史
                map.put("vaccinationhistory", EmrParserUtil.subStr(getMRXmlText(lc), 1000));
            }
            if ("MR-1001-1002-1023".equals(chapterId)) {
                // 系统回顾
                map.put("systematicreview", EmrParserUtil.subStr(getMRXmlText(lc), 2000));
            }
            if ("MR-1001-1002-1022".equals(chapterId)) {
                // 病史摘要
                map.put("medicalhistorysummary", EmrParserUtil.subStr(getMRXmlText(lc), 2000));
            }
            if ("MR-1001-1002-1024".equals(chapterId)) {
                // 专科情况
                map.put("spcy_info", EmrParserUtil.subStr(getMRXmlText(lc), 4000));
            }
            if ("MR-1001-1002-1011".equals(chapterId)) {
                // 辅助检查结果
                map.put("asst_exam_rslt", EmrParserUtil.subStr(getMRXmlText(lc), 4000));
            }
            if ("MR-1001-1008-1006".equals(chapterId)) {
                // 入院情况
                map.put("ryqk", EmrParserUtil.subStr(getMRXmlText(lc), 4000));
            }
            if ("MR-1001-1008-1008".equals(chapterId)) {
                // 诊疗过程
                map.put("zlgc", EmrParserUtil.subStr(getMRXmlText(lc), 4000));
            }
            if ("MR-1001-1008-1007".equals(chapterId)) {
                // 出院情况
                map.put("cyqk", EmrParserUtil.subStr(getMRXmlText(lc), 4000));
            }
            if ("MR-1001-1008-1004".equals(chapterId)) {
                // 出院医嘱
                map.put("cyyz", EmrParserUtil.subStr(getMRXmlText(lc), 4000));
            }
        }

        //组合数据
        //一般状况 检查结果
        List<String> physexm_ordn_stas_list = new ArrayList<>();
        physexm_ordn_stas_list.add("T:" + map.getOrDefault("temperature", "") + "℃");
        physexm_ordn_stas_list.add("P:" + map.getOrDefault("heartrate", "") + "次/分");
        physexm_ordn_stas_list.add("R:" + map.getOrDefault("breathrate", "") + "次/分");
        physexm_ordn_stas_list.add("BP:" + map.getOrDefault("sbp", "") + "/" + map.getOrDefault("dbp", "") + "mmHg");
        physexm_ordn_stas_list.add("意识:" + map.getOrDefault("consciousness", "清晰"));
        physexm_ordn_stas_list.add("体位:" + map.getOrDefault("position", "自动体位"));
        physexm_ordn_stas_list.add("身高:" + map.getOrDefault("height", "") + "cm");
        physexm_ordn_stas_list.add("体重:" + map.getOrDefault("weight", "") + "kg");
        physexm_ordn_stas_list.add("病容:" + map.getOrDefault("sicklylook", "正常"));
        physexm_ordn_stas_list.add("查体:" + map.getOrDefault("cooperation", "查体配合"));
        String physexm_ordn_stas = physexm_ordn_stas_list.stream().collect(Collectors.joining(" "));
        map.put("physexm_ordn_stas", physexm_ordn_stas);

        //皮肤和黏膜检查结果
        List<String> physexm_skin_musl_list = new ArrayList<>();
        physexm_skin_musl_list.add("色泽:" + map.getOrDefault("colourandlustre", "正常"));
        physexm_skin_musl_list.add("水肿:" + map.getOrDefault("edema", "无"));
        physexm_skin_musl_list.add("皮疹:" + map.getOrDefault("erythra", "未见"));
        physexm_skin_musl_list.add("出血:" + map.getOrDefault("haemorrhage", "无"));
        String physexm_skin_musl = physexm_skin_musl_list.stream().collect(Collectors.joining(" "));
        map.put("physexm_skin_musl", physexm_skin_musl);

        //头部及其器官检查结果
        List<String> physexm_head_list = new ArrayList<>();
        physexm_head_list.add("头部:"
                + " 外形:" + map.getOrDefault("headshape", "无畸形")
                + " 头皮:" + map.getOrDefault("headscalp", "正常")
                + " 头发:" + map.getOrDefault("headhair", "正常")
        );
        physexm_head_list.add("眼:"
                + " 眼球:" + map.getOrDefault("eyeball", "正常")
                + " 眼睑:" + map.getOrDefault("eyelid", "正常")
                + " 结膜:" + map.getOrDefault("conjunctiva", "正常")
                + " 巩膜:" + map.getOrDefault("sclera", "正常")
                + " 角膜:" + map.getOrDefault("corneal", "正常")
                + " 瞳孔:" + map.getOrDefault("pupil", "对称")
        );
        physexm_head_list.add("耳:"
                + " 耳廓:正常"
                + " 外耳道:" + map.getOrDefault("externalauditorycanal", "正常")
                + " 乳突压痛:无"
                + " 听力粗测:" + map.getOrDefault("roughlisteningtest", "正常")
                + " 耳鼻出血:无"
        );
        physexm_head_list.add("鼻:"
                + " 外形:" + map.getOrDefault("noseshape", "正常")
                + " 鼻通气:" + map.getOrDefault("nasalventilation", "通顺")
                + " 副鼻窦压痛:" + map.getOrDefault("tendernessofparanasalsinus", "无")
                + " 出血:无"
        );
        physexm_head_list.add("口腔:"
                + " 唇色:" + map.getOrDefault("lipcolor", "正常")
                + " 口腔粘膜:" + map.getOrDefault("oralmucosa", "完整")
                + " 牙齿:" + map.getOrDefault("tooth", "正常")
                + " 齿龈:" + map.getOrDefault("gums", "正常")
                + " 舌:" + map.getOrDefault("tongue", "正常")
                + " 腮腺:" + map.getOrDefault("parotidgland", "正常")
                + " 咽:" + map.getOrDefault("pharynx", "无充血")
                + " 扁桃体:" + map.getOrDefault("tonsil", "无肿大")
        );
        String physexm_head = physexm_head_list.stream().collect(Collectors.joining("\r\n"));
        map.put("physexm_head", physexm_head);

        //todo 颈部检查结果
        List<String> physexm_neck_list = new ArrayList<>();
        physexm_neck_list.add("抵抗:无");
        physexm_neck_list.add("颈静脉:" + map.getOrDefault("jugularvein", "正常"));
        physexm_neck_list.add("气管位置:" + map.getOrDefault("positionoftrachea", "居中"));
        physexm_neck_list.add("甲状腺:" + map.getOrDefault("thyroid", "无肿大"));
        String physexm_neck = physexm_neck_list.stream().collect(Collectors.joining(" "));
        map.put("physexm_neck", physexm_neck);

        //胸部检查结果
        List<String> physexm_chst_list = new ArrayList<>();
        physexm_chst_list.add("形状:" + map.getOrDefault("thoracicshape", ""));
        physexm_chst_list.add("呼吸:" + map.getOrDefault("chestbreathing", ""));
        physexm_chst_list.add("胸壁:" + map.getOrDefault("chestwall", ""));
        physexm_chst_list.add("肋间隙:" + map.getOrDefault("costalpace", ""));
        physexm_chst_list.add("乳房:" + map.getOrDefault("breast", ""));
        String physexm_chst = physexm_chst_list.stream().collect(Collectors.joining(" "));
        map.put("physexm_chst", physexm_chst);

        //腹部检查结果
        List<String> physexm_abd_list = new ArrayList<>();
        physexm_abd_list.add("外形:" + map.getOrDefault("abdominalshape", ""));
        physexm_abd_list.add("蠕波动:" + map.getOrDefault("creepwave", ""));
        physexm_abd_list.add("腹壁紧张度:" + map.getOrDefault("bdominalwalltension", ""));
        physexm_abd_list.add("腹部压痛:" + map.getOrDefault("abdominaltenderness", ""));
        physexm_abd_list.add("反跳痛:" + map.getOrDefault("reboundpain", ""));
        physexm_abd_list.add("腹部包块:" + map.getOrDefault("abdominalmass", ""));
        physexm_abd_list.add("肝脏:" + map.getOrDefault("hepar", ""));
        physexm_abd_list.add("胆囊:" + map.getOrDefault("gallbladder", ""));
        physexm_abd_list.add("脾脏:" + map.getOrDefault("spleen", ""));
        physexm_abd_list.add("肾区叩痛:" + map.getOrDefault("renalpercussionpain", ""));
        physexm_abd_list.add("肠鸣音:" + map.getOrDefault("bowelsounds", ""));
        physexm_abd_list.add("移动性浊音:" + map.getOrDefault("mobilevoicedsound", ""));
        String physexm_abd = physexm_abd_list.stream().collect(Collectors.joining(" "));
        map.put("physexm_abd", physexm_abd);

        //脊柱检查结果
        List<String> physexm_spin_list = new ArrayList<>();
        physexm_spin_list.add("畸形:" + map.getOrDefault("spinaldeformity", "无畸形"));
        physexm_spin_list.add("压痛:无");
        physexm_spin_list.add("活动度:正常");
        physexm_spin_list.add("其他:无");
        String physexm_spin = physexm_spin_list.stream().collect(Collectors.joining(" "));
        map.put("physexm_spin", physexm_spin);

        //神经系统检查结果
        List<String> nersys_list = new ArrayList<>();
        nersys_list.add("深、浅感觉:正常");
        nersys_list.add("深反射:正常");
        nersys_list.add("浅反射:正常");
        nersys_list.add("病理反射:阴性");
        nersys_list.add("脑膜刺激征:未引出");
        nersys_list.add("其他:" + map.getOrDefault("othernervoussystem", "无"));
        String nersys = nersys_list.stream().collect(Collectors.joining(" "));
        map.put("nersys", nersys);

        return map;
    }
}
